package net.freebytes.chat;

import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.sctp.nio.NioSctpServerChannel;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.handler.codec.string.StringDecoder;
import io.netty.handler.codec.string.StringEncoder;

/**
 * @description:
 * @author: lin
 * @time: 2024/12/3 17:56
 */
public class Server {

    public static void main(String[] args) {
        new ServerBootstrap().group(new NioEventLoopGroup()).channel(NioServerSocketChannel.class).childHandler(
                new ChannelInitializer<NioSocketChannel>() {
                    @Override
                    protected void initChannel(NioSocketChannel ch) throws Exception {
                        ch.pipeline().addLast(new StringDecoder());     // 解码
                        ch.pipeline().addLast(new StringEncoder());     // 编码

                        ch.pipeline().addLast(new ClientRegisterHandler());
                        ch.pipeline().addLast(new AiAnswerHandler());
                    }
                }).bind(8089);
    }

}
